#include "stdio.h"
#include <gsl/gsl_errno.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_odeiv2.h>
int f( double t, const double y[], double f[], void *param){
  f[0] = y[1];  
  f[1] = -3*y[0] -2*y[1]  + uu;  // x1dot = x2;  x2dot= -3x1 -2x2 + u
  return GSL_SUCCESS;
}

int main(int argc, char **argv)
{
  double y[2] = {1.0, -0.5};
  double t = 0, t1=0.01;
  double abseps = 1e-6, releps = 1e-6;
  gsl_odeiv2_system  sys = {f, NULL, 2, 0, 0};

  if(3!=argc) { puts("wrong argc"); exit(1); }
  y[0] = atof(argv[1]);
  y[1] = atof(argv[2]);

  gsl_odeiv2_driver *d = gsl_odeiv2_driver_alloc_y_new( &sys, gsl_odeiv2_step_rkf45, abseps, releps, 1e-6);
  int status;
  //do{
    status = gsl_odeiv2_driver_apply( d, &t, t1, y);
    if( status != GSL_SUCCESS) {puts("wrong");}
    printf("%.6f\n",  y[0]);
    printf("%.6f\n",  y[1]);
    //printf("t=%.4f y=%.4f\n", t, y[0]);
  //}while( t1<10 );

  gsl_odeiv2_driver_free(d);
  return 0;
}
